import {
  IViewController,
  ViewEngineBase,
  IIndexViewState,
  IViewEvent,
  IAppMenuController,
} from '@ibiz-template/runtime';
import { IAppIndexView } from '@ibiz/model-core';

export class IndexViewEngine extends ViewEngineBase {
  protected declare view: IViewController<
    IAppIndexView,
    IIndexViewState,
    IViewEvent
  >;

  get appmenu(): IAppMenuController {
    return this.view.getController('appmenu') as IAppMenuController;
  }

  initViewState(): void {
    super.initViewState();
    this.view.state.isCollapse = false;
  }

  async onCreated(): Promise<void> {
    await super.onCreated();
    this.view.childNames.push('appmenu');

    // 清除加载动画
    const el = document.getElementById('app-loading-x') as HTMLDivElement;
    if (el) {
      el.style.display = 'none';
    }
  }

  protected calcViewHeaderVisible(): boolean {
    return true;
  }
}
